package com.idea.plugin.action;

import com.idea.plugin.core.constant.Constants;
import com.idea.plugin.helper.IdeActionHelper;
import com.idea.plugin.helper.IdeEventInfo;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;

/**
 * @author yanzhao
 * @date 2022/2/16 10:23
 * @since 1.0.0
 */
public class TestingAction extends AnAction {

    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {

    }

    @Override
    public void update(@NotNull AnActionEvent e) {
        IdeEventInfo eventInfo = IdeActionHelper.getCurrentEvent(e);
        VirtualFile file = eventInfo.getVirtualFile();
        String filePath = file.getPath();
        e.getPresentation().setVisible(
                filePath.endsWith(Constants.IS_JAVA_FILE) &&
                        filePath.contains(Constants.PATH_TOKEN)
        );

    }
}
